package com.servlet;

import com.dao.imp.FindOrder;
import com.entity.Order;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/12/3 14:52
 **/

@WebServlet(name = "AliPayServlet", value = "/AliPayServlet")
public class AliPayServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int order_id = Integer.parseInt(request.getParameter("order_id"));
        int payPrice = Integer.parseInt(request.getParameter("totalPrice"));
        String sql = "SELECT * FROM orders WHERE order_id="+order_id;
        Order order = FindOrder.getOrderInfo(sql);
        request.setAttribute("Order",order);
        request.setAttribute("payPrice",payPrice);
        request.getRequestDispatcher("alipay.trade.page.pay.jsp").forward(request,response);
    }
}
